
/** ibrg code **/
YAHOO.namespace('alw.ibrpg');
var yud=YAHOO.util.Dom,yue=YAHOO.util.Event;

YAHOO.alw.ibrpg = {
	globals: {
		version: '0.04',
		//domain: 'yahoo.com',
		domain: 'castlewolfric.com',
		//domain: 'welcomefamous-corp-yahoo-com.local',
		main_panel:null,
		alert_panel:null,
		char_class: [
			{name:'warrior',img:"%2F%2F%2FyAgIBAQEDAwMJllMKqqqs6ZZZllAFVVVURERHV1dYmJiWUwAN7e3okAAM7OzmVlZWVlmc6ZAM7Omf%2BZAGUAALq6ugAAZQCZzs5l%2F2UAmZmZzpkAzgB1AAAARABVAP%2FOMGWZAM4AAACZAP%2FOAGUwZTAAADBlADDOAO7u7gBEAABlmZmZmQBl%2F87OZc7O%2F7oAAGUwMP%2FOZVUAAP9lMAAA3mXOzs6ZMM6ZzkQAAGXO%2FwCZmc5lAP%2F%2FAM4wZZkAZWUAMJmZMP%2F%2Fzv8wmTAwmQBlzpn%2F%2FzAwAAAAqpnOAP%2BZMGUw%2F5nOZQCZ%2FzAwZc5lMM7OAP9lAACqAP8AAAAAmZkwMJllZf%2F%2FmWUAZf%2BZZWVlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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QkTe7dyPWDAr4C2Z%2Fe2DS277VqFr7NSJBzggG%2FaeyUIh5t7bubZDHzX3msVNkewvpP%2Flt3T4GuOWQX8ZiidutSysGFrdD%2FwWkB3x9kR5vaevLz00GDBfie4HjZ58uXNK0dfXWD9BGppt55%2B8MlGXkQ6SSdcQ%2FnN4OAMmmVV13cE4idADDM0tNCDEDII4IEhMXhhDDEwFCKJS2loFYkl%2BtcQiwxiJOKML5Y4o3U05qjjfC3tSB%2BNBgUEADs%3D"}
			],
		character: {
			name: "",
			chclass: "",
			experience:0,
			level:0,
			loot: [
				{name:'gold',amt:0}
			],
			equipment:[
				{name:'clothing', defense: 0, power: 0}
			],
			victories: [],
			health:10,
			power:1,
			defense:1
		},
		monsters: [
			{name:"rat",img:"%2F%2F%2FyAgIBAQEJllAJllMKqqqmUwAM6ZAHV1dVVVVc6ZZURERN7e3okAADAwMImJiWVlZQAAIM5lzmWZAP9lZbq6us7Ozv8AAABlZTCZmTBlAM7OmZkwmc4wMJmZmZkwAP%2BZMP%2FOAKoAAGVlmZkwMM5lMEQAAN4AAAAARM4wAAAAZf9lAP9lMM4AAJmZMJnOAP%2BZAHUAAAAAmQBl%2F2UAAM5lALoAADDOzs4Azs6ZMM6Zzv%2FOMGUAZWXOzgCZmQBVAM7OZWUwMABEAAAAzpkAmQAwZWVlMP%2FOZZkAzjAAAAAA3mWZ%2F2XO%2F85l%2F%2F%2FOmWUAmQB1ADDOAJllZf%2F%2FzmUwZWX%2FMM4wZQAAqpkAZQCZzmUw%2F1UAAP8wmZn%2F%2F5kAAABlmf8AMJnO%2FwCqAGUAMP%2BZmTAwZf%2F%2FAO7u7s7OAP8AZZn%2Fmf%2F%2FmQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAgACAAAAj%2FAAEIHEiwoMGDCBMqXMiwocOHEAcKmCggYsKJBzIemGixoICMEyYkSJCRYsePIkOGHKmRI0SUIhOoTDmhZMWGH0eq1LlSZs2NNxXmHOkz5k4JEloKRUpUp0%2BdSYmm2HjxQAIJRDMSDRk1QYoUJIMaHIr0QFeiSb%2BilSCW4EewI5EKwBrX6tqwCHOCNTvxKtauTFm2lWh3KtumZQN7nTpY4Nu9h%2BH6lQqX6kEBCEZO3QhWbVS1mi2PRZDZq4CmXtNSxjuWImnNoK8WlizaMcXbr2HLjk2yNoDbwDHnTnG2t0u3wYO%2F7mozb%2FLkCJI2F%2Fo8%2BHSc1YGfzN4R%2Be3u4MOLBB8%2FMCAAOw%3D%3D"}
		],
		weapons: [
			{name:"sword", img:"", power:2, defense: 0,cost: 200, type: 'weapon'},
			{name:"shield",img:"", power: 0, defense: 2, cost: 100, type: 'armor'}
		],
		locations: [
			{name:"chest",img:"%2F%2F%2FxAQEEBAQFVVVWVA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KDBgwRl%2BFD4T4kMIQSxCMGiRIlEHwUXLmxYUQkOGf8g%2FpOIJSQWHCFC4PCBEYvEgSFACpGhZGEIgUJ8TJQBMsRChTeFzGSI8WZKgjlDqoz5T6PGkT6D%2BsCREOTFkB8%2FYuTJs6mMrCOngnToMORXmSGEUD2IQ8hNiR9BchXIkuVagRkycMirNwNSLHP%2F3QxJdzCHD3n35v3AQbFfwSCbDrw4%2BB9fBJgza1Y8%2BanJjzf3NkYwsAZpgTX6foCM4yPOkzJuItZ7%2Bp%2Fp0n39xmwd2WBfDghqCDc9vAZixAiFYsGYOMMHzdBrNE48Uu3a5a5FO699GzVjxBxMbvIUHNWy3sPcuX%2FX%2B6%2F1%2BILNnxefvz68wakr%2FxUo8GE24%2BaqHZZXdRPR9ZN%2BBSwgwIIPDMDAA4qJNptfE00l0EqxIShAAgwOYMAAAzxwHgcScIZFShgZVEACC3AoQIMPRkgiCBUMaJByGO3Hl3MynvdPBeaFhJ9A2IGEAIATNnaYff%2FsFdZ4KMp25HmMaSfgf0661xtBES7Wo2ijPZaRewhOB95v%2FU3XF4ElNXXgfgp2GKNe9Q1Y4VoY3rTfhh1%2BGKJ2uUHl00ErtiiniOD1eBCOZSoJaKIACtkakWI12RyYi50X6XJQlpeYlYqd6aVfWv4TEAA7"}
		],
		registered: false,
		storageMirror: null,
		myAnim:null,
		myAnim2:null,
		myAnimWait:null,
		battleStats:{}
	},
	init: function(){
		var homeLink ="<a href='javascript:YAHOO.alw.ibrpg.displayHome()'>";
		if(window.globalStorage){
			homeLink+="<img src='"+YAHOO.alw.ibrpg.globals.locations[0].img+"' border='0' align='absmiddle'>";
		}
		homeLink+=" Itty Bitty RPG</a>";
		yud.get('ibrpg_home').innerHTML=homeLink;		
		
		this.globals.main_panel = new YAHOO.widget.Panel("panel_seven",
     		{ 
	    		close:true,  
	    		visible:false,  
	    		draggable:true,
	    		modal: true,
	    		constraintoviewport:true,
	    		effect:{effect:YAHOO.widget.ContainerEffect.FADE, duration: .5},
	    		xy: [100,100]
			} 
		);
		this.globals.alert_panel = new YAHOO.widget.Panel('ibrpg_alertpanel',
			{
				close: true,
				visible: false,
				width: "200px",
				xy: [-200,-200]
			
			}
		
		);
		if(this.getStorage()){
			//bump the experience! Kinda important...
			this.globals.storageMirror.experience++;
			this.putStorage();
			var thePanel = YAHOO.alw.ibrpg.globals.main_panel;
			thePanel.setHeader('Itty Bitty RPG ...');
			thePanel.setBody("loading interface...");
			thePanel.setFooter("<small>[<a href='http://code.google.com/p/ittybittyrpg/'>Itty Bitty RPG</a>]</small>");
			thePanel.render(document.body);
			this.renderElements();
			
			
			var theAlert = this.globals.alert_panel;
			theAlert.setHeader('IBRPG: ALERT');
			theAlert.setBody("Alert Message");
			theAlert.render(document.body);
			theAlert.show();
			
			this.globals.myAnim = new YAHOO.util.Motion('ibrpg_alertpanel_c', {points: 
	   			{ 	from:[(yud.getViewportWidth() -220),-100],
	   				to: [(yud.getViewportWidth() -220),10] } 
				});
				
			
			this.globals.myAnimWait = new YAHOO.util.Anim('ibrpg_alertpanel_c');
			this.globals.myAnimWait.duration = 1;
			
			this.globals.myAnim2 = new YAHOO.util.Motion('ibrpg_alertpanel_c', {points: 
	   			{ 	to:[(yud.getViewportWidth() -220),-100],
	   				from: [(yud.getViewportWidth() -220),10]
	   			 } 
				});
			function bar(type,args){
				YAHOO.alw.ibrpg.globals.myAnimWait.animate();
			}
			function foo(type,args){
				YAHOO.alw.ibrpg.globals.myAnim2.animate();
			}	
			this.globals.myAnim.onComplete.subscribe(bar)
			this.globals.myAnimWait.onComplete.subscribe(foo)
			
			//this.globals.myAnim.animate();
			//this.sendAlert('Whoo hoo!');
			//console.log('exp' + this.globals.storageMirror.experience)
			if(this.globals.storageMirror.experience % 10 == 0){
				this.sendAlert('Level Up!');
				this.globals.storageMirror.level++;
				this.putStorage();
			}
      this.updateTooltip();
		}
	},
	updateTooltip: function(){
	 var sm = YAHOO.alw.ibrpg.globals.storageMirror;
      if(sm.name != ''){
			yud.get('ibrpg_home').setAttribute('title',sm.name+', a level '+sm.level+' '+sm.chclass + ' with '+sm.experience+' experience.')
			}else{
			yud.get('ibrpg_home').setAttribute('title', 'Itty Bitty RPG: A web counter meets role playing game!');	
			}
			var myTooltip = new YAHOO.widget.Tooltip("ibrpg_home_tip", { context:"ibrpg_home" } );
  },
	sendAlert: function(message){
		var theAlert = this.globals.alert_panel;
		theAlert.setBody(message);
		this.globals.myAnim.animate()
	},
	getStorage: function(){
		//return false if storage not possible.
		if(window.globalStorage){
			var storage = globalStorage[this.globals.domain];//change to your domain
			if(storage.ibrpgtest && storage.ibrpgtest != ''){
				//console.log(storage.ibrpgtest)
				this.globals.storageMirror = storage.ibrpgtest.value.parseJSON();
				//console.log("storageMirror" )
				//console.log(this.globals.storageMirror);
				this.globals.registered = true;//safe assumption?
				return true;
			}else {
				//initialize storage
				storage.ibrpgtest = this.globals.character.toJSONString();
				this.globals.storageMirror = storage.ibrpgtest.value.parseJSON();
				//console.log(storage.ibrpgtest);
				return true;
			}
		}else{
			return false;
		}
	
	},
	putStorage: function(){
		if(window.globalStorage){
			var storage = globalStorage[this.globals.domain];//change to your domain
			storage.ibrpgtest = YAHOO.alw.ibrpg.globals.storageMirror.toJSONString();
			return true;
		}else{
			return false;
		}
	},
	renderElements: function(){
		var elArr = yud.getElementsByClassName('ibrpg','div')
		for(i = 0; i< elArr.length; i++){
			if(yud.hasClass(elArr[i],'monster')){
				elArr[i].innerHTML = YAHOO.alw.ibrpg.setUpMonster();
			}
			if(yud.hasClass(elArr[i],'random')){
				elArr[i].innerHTML = 'random';
			}
			if(yud.hasClass(elArr[i],'treasure')){
				elArr[i].innerHTML = YAHOO.alw.ibrpg.setUpTreasure();
			}
		}
	},
	setUpTreasure: function(){
		var items = YAHOO.alw.ibrpg.globals.items;
		outPut = "<a  href='#' onclick='YAHOO.alw.ibrpg.displayTreasure()'><img src='"+items[0].img+"' border='0'/></a>";
		return outPut;
		
	},
	displayTreasure: function(){
	 if(YAHOO.alw.ibrpg.globals.storageMirror.name !=''){
		var items = YAHOO.alw.ibrpg.globals.items;
		var gbl = YAHOO.alw.ibrpg.globals;
		var playerGold = gbl.storageMirror.loot[0]
		var randGold = Math.floor(Math.random() * 100);
		playerGold.amt += randGold;
		YAHOO.alw.ibrpg.putStorage();
		var thePanel = gbl.main_panel;
		outPut = "<img src='"+items[0].img+"'>  Congratulations! You got " +randGold+" gold!";
		thePanel.setBody(outPut);
		thePanel.show();
		}else{
      alert('you need to create a character first!')
    }
	},
	displayEquipment: function(){
		var equip = YAHOO.alw.ibrpg.globals.storageMirror.equipment
		var thePanel = YAHOO.alw.ibrpg.globals.main_panel;
		var eqTxt = "<div>Your equipment / attire </div>";
		for(i = 0; i < equip.length; i++){
			eqTxt += "<div style='margin: 5px 0;'> Item: <b>"+equip[i].name+"</b> Power: "+equip[i].power+" Defense: "+equip[i].defense+"</div>"; 
		}
		if(equip.length <1){
			eqTxt += "<div>No Items</div>";
		}
		eqTxt += "<div><a href='#' onclick='YAHOO.alw.ibrpg.globals.main_panel.hide()'>[ Close ]</div>"
		thePanel.setBody(eqTxt);
		thePanel.show();
	},
	displayStore: function(){
		var equip = YAHOO.alw.ibrpg.globals.storageMirror.equipment;
		var weapons = YAHOO.alw.ibrpg.globals.weapons;
		var thePanel = YAHOO.alw.ibrpg.globals.main_panel;
		wpTxt = "<div><b>Welcome to the Store!</b></div>";
		wpTxt += "<div>Here are the items I currently have in stock</div>";
		for(i=0; i< weapons.length; i++){
			wpTxt += "<div style='margin:5px 0;'>Item Name:<b>"+weapons[i].name+"</b> Defense:"+weapons[i].defense+" Power: "+weapons[i].power+" Cost: "+weapons[i].cost+" <a href='javascript:YAHOO.alw.ibrpg.buyWeapon("+i+")'>Buy</a></div>";
		}
		wpTxt += "<div><a href='#' onclick='YAHOO.alw.ibrpg.globals.main_panel.hide()'>[ Close ]</div>"
		thePanel.setBody(wpTxt);
		thePanel.show();
	},
	
	buyWeapon: function(i){
		var sm = YAHOO.alw.ibrpg.globals.storageMirror
		var equip = sm.equipment;
		var weapons = YAHOO.alw.ibrpg.globals.weapons;
		var thePanel = YAHOO.alw.ibrpg.globals.main_panel;
		//console.log(sm.loot[0].amt)
		//console.log(weapons[i].cost)
		if(sm.loot[0].amt >= weapons[i].cost){
			sm.equipment[sm.equipment.length] = weapons[i];
			sm.loot[0].amt -= weapons[i].cost;
			YAHOO.alw.ibrpg.putStorage();
			alert('You purchased the '+ weapons[i].name +' in the future you will be able to actually use it!');
			thePanel.hide();
		}else{
			alert('You dont have enought gold! Go kill some monsters or find a treasure chest!');
		}
	},
	setUpMonster: function(){
		var monsters = YAHOO.alw.ibrpg.globals.monsters
		var mIdx = Math.floor((Math.random() * (monsters.length)))
		var rndMonster = monsters[mIdx]
		//console.log(rndMonster);
		var outPut = "<a href='#' onclick='YAHOO.alw.ibrpg.doFight("+mIdx+")' title='IBRPG: monster encounter'><img src='"+rndMonster.img+"' border='0'></a>"
		return outPut;
	},
	doFight: function(m){
	 if(!YAHOO.alw.ibrpg.globals.storageMirror || YAHOO.alw.ibrpg.globals.storageMirror.name ==''){ alert('you need to create a character first!');return}
		var gbl = YAHOO.alw.ibrpg.globals;
		gbl.battleStats = {};
		var thePanel = gbl.main_panel;
		for(i = 0; i<gbl.char_class.length; i++){
			if(gbl.storageMirror.chclass == gbl.char_class[i].name){
				playerImg = gbl.char_class[i].img;
			}
		}
		var playerPower = gbl.storageMirror.power;
		//console.log(''+playerPower)
		var playerHealth = gbl.storageMirror.health;
		var playerDefense = gbl.storageMirror.defense;
		var playerLevel = gbl.storageMirror.level;
		
		var monsterLevel = Math.floor((playerLevel+3) * Math.random());
		monsterLevel == 0 ? monsterLevel++ : 0
		//console.log(monsterLevel)
		var monsterPower = Math.floor(monsterLevel * .8)
		monsterPower == 0 ? monsterPower++ :0;
		var monsterHealth = Math.floor(monsterLevel * 7 * Math.random())
		monsterHealth == 0 ? monsterHealth = 10: 0;
		var monsterDefense = Math.floor(monsterPower *Math.random())
		gbl.battleStats = {whosturn:'player',pp:playerPower, ph: playerHealth, pd: playerDefense, mp: monsterPower, mh: monsterHealth, md: monsterDefense, monsterName: YAHOO.alw.ibrpg.globals.monsters[m].name}

		var battleText = "<table><tr><td colspan='3'><div style='text-align:center;'>Battle!</div></td></tr>";
		battleText+= "<tr><td style='width:33%; text-align:center;'><div id='ibrpg_battleplayerimg'> <img src='"+playerImg+"'></div>"; 
		battleText+="<div>"+YAHOO.alw.ibrpg.globals.storageMirror.name+"</div>";
		battleText+="<div style='font-size: 60%;'>PWR:<span id='ibrpg_plpwr'>"+playerPower+"</span> DEF:<span id='ibrpg_pldef'>"+playerDefense+"</span> HLTH: <span id='ibrpg_plhlth'>"+playerHealth+"</span></div></td>";
		battleText+="<td style='width:33%;text-align:center;'><div><strong>--VS--</strong></div></td>";
		battleText+="<td style='width:33%;text-align:center;'><div id='ibrpg_battlemonsterimg'> <img src='"+YAHOO.alw.ibrpg.globals.monsters[m].img+"'></div> <div>"+YAHOO.alw.ibrpg.globals.monsters[m].name+"</div>"
		battleText+="<div style='font-size: 60%;'>PWR:<span id='ibrpg_monpwr'>"+monsterPower+"</span> DEF:<span id='ibrpg_mondef'>"+monsterDefense+"</span> HLTH: <span id='ibrpg_monhlth'>"+monsterHealth+"</span></div></td></tr>";
		battleText+="<tr><td colspan='3' style='text-align:center'><div id='ibrpg_battlestats'><button value='Fight' onclick='YAHOO.alw.ibrpg.progressFight()'>Fight!</button> --- <button value='Flee!' onclick='YAHOO.alw.ibrpg.globals.main_panel.hide()'>Flee!</button></div></td></tr>";
		battleText+="</table>";
		
		thePanel.setBody(battleText);
		thePanel.show();
		
	},
	progressFight: function(){
		var theScreen = yud.get('ibrpg_battlestats');
		var gbl = YAHOO.alw.ibrpg.globals;
		var outPut = '...you prepare yourself';
		var canContinue = true;
		if (gbl.battleStats.ph<=0){
			outPut = "You have been knocked out. Battle over! You have failed.";
			canContinue = false;
			}
		else if (gbl.battleStats.mh<=0){
			var gbl = YAHOO.alw.ibrpg.globals;
			var playerGold = gbl.storageMirror.loot[0]
			var randGold = Math.floor(Math.random() * 10) +1;
			playerGold.amt += randGold;
			YAHOO.alw.ibrpg.putStorage();
			outPut = "You have defeated the "+ gbl.battleStats.monsterName+"! You get "+randGold+" gold.";
			canContinue = false;
		}
		else if(gbl.battleStats.whosturn == "player"){
			percentHit = Math.floor(Math.random() * 100)
			if(percentHit <=85){
				damage = Math.floor(gbl.battleStats.pp * Math.random())+1;
				gbl.battleStats.mh-=damage;
				outPut = "You hit the "+gbl.battleStats.monsterName+" for "+damage+" damage!";
				gbl.battleStats.whosturn = "monster";//now its monsters turn
			}else{
				outPut = "You missed! Whoops!";
			}
		}
		else if(gbl.battleStats.whosturn == "monster"){
			percentHit = Math.floor(Math.random() * 100);
			if(percentHit <= 75){
				damage = Math.floor(Math.random() * gbl.battleStats.mp)+1;
				gbl.battleStats.ph-=damage;
				YAHOO.alw.ibrpg.globals.storageMirror.health = gbl.battleStats.ph;
				YAHOO.alw.ibrpg.putStorage();
				outPut = "The "+gbl.battleStats.monsterName+" hit you for " +damage + " damage! Oof!";
				gbl.battleStats.whosturn ="player";// time for player to smak down
			}
		}
		YAHOO.alw.ibrpg.updateBattleStatsView();
		theScreen.innerHTML = outPut;
		if(canContinue){
			setTimeout("YAHOO.alw.ibrpg.progressFight()",1000);
		}
	},
	updateBattleStatsView: function(){
		var btl = YAHOO.alw.ibrpg.globals.battleStats;
		
		yud.get('ibrpg_plpwr').innerHTML = btl.pp;
		yud.get('ibrpg_pldef').innerHTML = btl.pd;
		yud.get('ibrpg_plhlth').innerHTML = btl.ph;
		yud.get('ibrpg_monpwr').innerHTML = btl.mp;
		yud.get('ibrpg_mondef').innerHTML = btl.md;
		yud.get('ibrpg_monhlth').innerHTML = btl.mh;
	},
	displayHome: function (){
		var thePanel = YAHOO.alw.ibrpg.globals.main_panel;
		var initialText ='', msgText = '';
		
		if(this.globals.registered && this.globals.storageMirror.name != ''){
			msgText += "<div>Welcome back, "+this.globals.storageMirror.name +" .</div>"
			msgText +="<div>Class:<b>"+this.globals.storageMirror.chclass+"</b> EXP: <em>"+this.globals.storageMirror.experience +"</em></div>";
			msgText +="<div>Gold:<b>"+this.globals.storageMirror.loot[0].amt+"</b> HEALTH: <b>"+this.globals.storageMirror.health+"</b> </div>";
			//msgText += "<a href='#' onclick='YAHOO.alw.ibrpg.signUp()'>Change character.</a>"
		}else{
			msgText +="Welcome to Itty Bitty RPG <br>";
			msgText += "Not just a web counter, this is a <br>";
			msgText += "fun little RPG. Visit pages, collect<br>";
			msgText += "experience, battle monsters, find treasure!<br>";
			msgText += "Simply click Create/Edit Character<br> to create a character!";
		}
		
		initialText +="<table cellpadding='5'><tr><td><img src='"+YAHOO.alw.ibrpg.globals.locations[0].img+"' align='absmiddle'/>Your Village</td><td></td></tr>";
		initialText +="<tr><td><ul><li><a href='javascript:YAHOO.alw.ibrpg.signUp()'>Create/Edit Character</a></li>";
		initialText +="<li><a href='javascript:YAHOO.alw.ibrpg.globals.storageMirror.health=10;alert(\"health restored\");YAHOO.alw.ibrpg.globals.main_panel.hide();'>Rest/Recover</a></li>";
		initialText +="<li><a href='javascript:YAHOO.alw.ibrpg.displayStore()'>Shop</a></li>";
		initialText +="<li><a href='javascript:YAHOO.alw.ibrpg.displayEquipment()'>Inventory</a></li>";
		initialText +="</ul></td>"+msgText+"</tr></table>";
		
		if(window.globalStorage){
			thePanel.setBody(initialText);
			thePanel.show();
			}else{
				alert('Itty Bitty RPG is a web-based RPG that requires Firefox 2.0 (and up) - please visit using that browser and try again!');
			}
		
	},
	signUp: function(){
		var thePanel = YAHOO.alw.ibrpg.globals.main_panel;
		var theClasses = YAHOO.alw.ibrpg.globals.char_class;
		var chosenClass = YAHOO.alw.ibrpg.globals.storageMirror.chclass;
		var classIndex = 0;
		//thePanel.hide();
		var signUp = "<form id='ibrpgcharform'>";
		signUp +="Choose a name: <input type='text' id='ibrpgcharname' value='"+YAHOO.alw.ibrpg.globals.storageMirror.name+"'><br>";
		signUp += "Choose a class: <select id='ibrpgclassname' onchange='YAHOO.alw.ibrpg.updatePreview()'>";
		for(i=0; i< theClasses.length; i++){
			if(theClasses[i].name === chosenClass){
				classIndex = i;
				signUp+="<option selected='true'>"+theClasses[i].name+"</option>";
			}else{
				signUp+="<option>"+theClasses[i].name+"</option>";
			}
		}
		signUp +="</select>";
		signUp += "</form>";
		signUp +="<div style='text-align: left;'><img id='ibrpg_imgpreview' src='"+theClasses[classIndex].img+"'></div>";
		signUp +="<a href='#' onclick='YAHOO.alw.ibrpg.setChar();YAHOO.alw.ibrpg.globals.main_panel.hide()'>Start Adventuring!</a>";
		thePanel.setBody(signUp);
		//thePanel.show();
		
	},
	updatePreview: function(){
		var selIdx = document.getElementById('ibrpgclassname').selectedIndex;
		var srcData = YAHOO.alw.ibrpg.globals.char_class[selIdx].img
		document.getElementById('ibrpg_imgpreview').setAttribute('src',srcData);
	},
	setChar: function(){
		var charName = yud.get('ibrpgcharname').value;
		var chClass = yud.get('ibrpgclassname').value;
		//console.log(charName);
		//console.log(chClass);
		YAHOO.alw.ibrpg.globals.storageMirror.name = charName;
		YAHOO.alw.ibrpg.globals.storageMirror.chclass = chClass;
		YAHOO.alw.ibrpg.saveVals();
		YAHOO.alw.ibrpg.updateTooltip();
		
	},
	saveVals: function(){
		//console.log('in saveVals') 
		this.globals.registered = true;
		YAHOO.alw.ibrpg.putStorage();
		//console.log(storage.ibrpg)
	}
}

yue.on(window, 'load',YAHOO.alw.ibrpg.init,YAHOO.alw.ibrpg, true);

